package ewu

import ewu._
import java.util.ArrayList
import scala.collection.mutable.ArrayBuffer

/**
 * Diese Klasse erbt von der Boolexpression-Klasse und
 * stellt einen Negationsoperator dar.
 * Beispiel: Not(x)
 */

case class Not (expr: BoolExpression) extends BoolExpression {

  def evaluate (env: Environment): Option[Boolean] =
      expr.evaluate(env) match {
    case Some(exp) => Some(!(exp))
    case _ => None
  }

  override def toString: String = "NOT(" + expr + ")"

  def reduce: BoolExpression = {
    if (expr.reduce.isTrue) new False
    else Not(expr.reduce)
  }

  def isTrue: Boolean = !expr.isTrue
  
  def getVariables(a: ArrayBuffer[Name]) = {
    expr.getVariables(a)
  }
  
  override def replaceQuantor(addfuncs: ArrayList[String], arrayvars: ArrayList[String]) : BoolExpression = {
    return new Not(expr.replaceQuantor(addfuncs, arrayvars))
  }
}


 